<template>
	<view class="">
		<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
			@scrolltolower="lower" @scroll="scroll">
			<view class="content_box">
				<view class="title_small">
					<text>健康套餐</text>
				</view>
				<view class="contents" v-for="item in listVal" :key="item.id">
					<view class="order1">
						<image style="width: 172rpx;height: 146rpx;display: block;" :src="item.imgurl" mode="">
						</image>
					</view>
					<view class="food_val">
						<text class="qiguoji">{{item.name}}</text>
						<view
							style="display: flex;justify-content: space-between;margin-top: 66rpx;align-items: center;">
							<text class="price">{{'￥'+item.priceval}}</text><text class="y">预定三天</text>
							<view class="number_box" style="width: 126rpx;display: flex;">
								<view @click="handelNumberBox('del',item.id)">
									<image style="width: 36rpx;height: 36rpx;" src="../static/img/jianshao.png" mode="">
									</image>
								</view>
								<text style="width: 50px;text-align: center;" class="input">{{item.numberval}}</text>
								<view @click="handelNumberBox('add',item.id)">
									<image style="width: 38rpx;height: 38rpx;" src="../static/img/tianjia.png" mode="">
									</image>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				
				listVal: [{
					type: "warning",
					value: 100,
					name: "椒盐汽锅鸡",
					priceval: "122",
					imgurl: "../static/img/food1.png",
					id: "1",
					numberval: 0
				}, {
					name: "麻辣汽锅鸡",
					priceval: "122",
					imgurl: "../static/img/food1.png",
					id: "2",
					numberval: 0
				}, {
					name: "红烧汽锅鸡",
					priceval: "122",
					imgurl: "../static/img/food1.png",
					id: "3",
					numberval: 0
				}, ]
			}
		},
		onLoad() {

		},
		methods: {
			valChange(e) {
				console.log('当前值eeeeee ', this.$refs.numberbox)
			},
			handelNumberBox(val, num) {
				this.listVal.forEach((item) => {
					if (item.id == num) {
						if (val == 'add') {
							item.numberval++
						} else if (val == 'del') {
							if (item.numberval == 0) {
								item.numberval = 0
							} else {
								item.numberval--
							}
						}
					} else {
						return
					}
				})
				console.log('this.listVal', this.listVal);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.u-number-box {
		width: 124rpx;
	}

	.content_box {
		padding: 25rpx;
	}

	.minus {
		width: 22px;
		height: 22px;
		border-width: 1px;
		border-color: #E6E6E6;
		border-style: solid;
		border-top-left-radius: 100px;
		border-top-right-radius: 100px;
		border-bottom-left-radius: 100px;
		border-bottom-right-radius: 100px;
		@include flex;
		justify-content: center;
		align-items: center;
	}

	.input {
		padding: 0 10px;
	}

	.plus {
		width: 22px;
		height: 22px;
		background-color: #FF0000;
		border-radius: 50%;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: center;
		align-items: center;
	}

	.contents {
		display: flex;
		justify-content: space-between;
		width: 526rpx;
		background-color: #fff;
		margin-bottom: 20rpx;

		.qiguoji {
			width: 224rpx;
			height: 44rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #333333;
			line-height: 44rpx;
			text-align: left;
			font-style: normal;
			text-transform: none;
			overflow: hidden;
			/* 隐藏超出的部分 */
			white-space: nowrap;
			/* 不换行 */
			text-overflow: ellipsis;
			/* 显示省略号 */
		}

		.price {
			width: 120rpx;
			height: 40rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 28rpx;
			color: #FF1000;
			line-height: 40rpx;
			text-align: left;
			font-style: normal;
			text-transform: none;
		}

		.food_val {
			width: 362rpx;
		}
	}

	.title_small {
		width: 112rpx;
		height: 40rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: bold;
		font-size: 28rpx;
		color: #333333;
		line-height: 40rpx;
		margin-bottom: 20rpx;
		text-align: left;
		font-style: normal;
		text-transform: none;
	}
</style>